<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<link rel="icon" type="image/png" href="{{ url_for('static', filename='favicon.png') }}">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

	<title>FAME</title>

	<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
    <meta name="viewport" content="width=device-width" />


    <!-- Bootstrap core CSS     -->
    <link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet" />

    <!-- Template CSS -->
    <link href="{{ url_for('static', filename='css/template.css') }}" rel="stylesheet"/>

    <!-- Animation -->
    <link href="{{ url_for('static', filename='css/animate.css') }}" rel="stylesheet"/>

    <!-- FAME CSS -->
    <link href="{{ url_for('static', filename='css/fame.css') }}" rel="stylesheet" />

    <!--     Fonts and icons     -->
    <link href="{{ url_for('static', filename='css/font-awesome.min.css')}}" rel="stylesheet">
    <link href='https://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
    <link href="{{ url_for('static', filename='css/pe-icon-7-stroke.css')}}" rel="stylesheet" />

    <!-- Highlight Theme -->
    <link href="{{ url_for('static', filename='css/highlight.railscasts.min.css')}}" rel="stylesheet" />

    <!--   Core JS Files   -->
    <script src="{{ url_for('static', filename='js/jquery-1.11.3.min.js') }}" type="text/javascript"></script>
	<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}" type="text/javascript"></script>

    <!-- Template JS -->
	<script src="{{ url_for('static', filename='js/template.js') }}"></script>
    <script src="{{ url_for('static', filename='js/checkbox.js') }}"></script>

    <!-- Bootstrap Notifications -->
    <script src="{{ url_for('static', filename='js/bootstrap-notify.min.js') }}"></script>

    <!-- FAME JS -->
    <script src="{{ url_for('static', filename='js/fame.js') }}"></script>

    <!-- File inputs -->
    <link href="{{ url_for('static', filename='css/fileinput.min.css') }}" rel="stylesheet" />
    <script src="{{ url_for('static', filename='js/fileinput.min.js') }}"></script>

    <!-- Highlight JS -->
    <script src="{{ url_for('static', filename='js/highlight.min.js') }}"></script>

    <!-- Tags Input -->
    <script src="{{ url_for('static', filename='js/tagsinput.js') }}"></script>

    <!-- Typeahead -->
    <script src="{{ url_for('static', filename='js/typeahead.bundle.min.js') }}"></script>

    <!-- Handlebars -->
    <script src="{{ url_for('static', filename='js/handlebars.min.js') }}"></script>
</head>
<body>

<div class="wrapper">
    <div class="sidebar" data-color="azure" data-image="{{ url_for('static', filename='img/sidebar.jpg') }}">

    	<div class="sidebar-wrapper">
            <div class="logo">
                <a href="/" class="simple-text">
                    FAME
                </a>
            </div>

            <div id="sidebar-nav">
            <ul class="nav auto-update" id="sidebar-content">
                {% block sidebar %}
                    <li>
                        <a>
                            <i class="fa fa-magic"></i>
                            <p>Last Analyses</p>
                        </a>
                    </li>
                    {% for analysis in g.last_analyses %}
                        <li>
                            <a href="{{ url_for('AnalysesView:get', id=analysis._id) }}">
                                <div class="last-analyses-status">
                                    {% if analysis.status == 'running' %}
                                        <i class="fa fa-refresh text-warning spinner"></i>
                                    {% elif analysis.status == 'finished' %}
                                        <i class="fa fa-check text-success"></i>
                                    {% elif analysis.status == 'pending' %}
                                        <i class="fa fa-clock-o text-warning spinner"></i>
                                    {% elif analysis.status == 'error' %}
                                        <i class="fa fa-warning text-danger"></i>
                                    {% endif %}
                                    <div>{{ analysis.status }}</div>
                                </div>

                                <div class="small">
                                    {% if not analysis.file.type == 'url' %}
                                        {{analysis.file.md5}}
                                    {% endif %}
                                </div>
                                <div>
                                    {{analysis.file.names|join(', ')}}
                                </div>

                                {% if analysis.probable_names %}
                                    <div>
                                        <strong>{{analysis.probable_names|join(', ')}}</strong>
                                    </div>
                                {% endif %}
                            </a>
                        </li>
                    {% endfor %}

                    <script>
                        auto_update("{{ url_for('AnalysesView:new') }}", 60000, '#sidebar-content');
                    </script>
                {% endblock %}
            </ul>
        </div>
    	</div>
    </div>

    <div class="main-panel">
        <nav class="navbar navbar-default navbar-fixed">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation-example-2">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand">{% block title %} {% endblock %}</a>
                </div>
                <div class="collapse navbar-collapse">
                    <form class="navbar-form navbar-left navbar-search-form" role="search" action="{{ url_for('SearchView:post') }}" method="post">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-search"></i></span>
                            <input type="text" name="query" value="" class="form-control" placeholder="Search...">
                        </div>
                    </form>

                    <ul class="nav navbar-nav navbar-right">
                        {% if current_user.has_permission('configs') %}
                        <li>
                           <a href="{{ url_for('ConfigsView:index') }}">
                               Configs
                            </a>
                        </li>
                        {% endif %}
                        <li>
                            <a href="{{ url_for('FilesView:index') }}">
                                Objects
                            </a>
                        </li>
                        <li>
                            <a href="{{ url_for('AnalysesView:index') }}">
                                Analyses
                            </a>
                        </li>
                        <li>
                            <a href="{{ url_for('AnalysesView:new') }}">
                                Submit
                            </a>
                        </li>
                        <li class="menu-avatar avatar dropdown">
                            <a href="#" id="avatar-dropdown" class="dropdown-toggle" data-toggle="dropdown">
                                <img class="img-circle" src="{{current_user._id|avatar}}" />
                            </a>

                            <ul class="dropdown-menu">
                              <li><a href="{{url_for('UsersView:get', id=current_user._id)}}">Profile</a></li>
                              {% if current_user.has_permission('manage_modules') %}
                                <li><a href="{{ url_for('ModulesView:index') }}">Configuration</a></li>
                              {% endif %}
                              {% if current_user.has_permission('manage_users') %}
                                <li><a href="{{ url_for('UsersView:index') }}">Users</a></li>
                              {% endif %}
                              <li><a href="/logout">Logout</a></li>
                            </ul>
                        </li>

                    </ul>
                </div>
            </div>
        </nav>


        <div class="content">
            <div class="container-fluid auto-update" id="main-content">
                {% with messages = get_flashed_messages(category_filter=["persistent"]) %}
                  {% if messages %}
                      <div class="row">
                          <div class="col-md-12">
                              <div class="card messages">
                                  <div class="header">
                                      <h4 class="title">Messages</h4>
                                      <p class="category"></p>
                                  </div>
                                  <div class="content">
                                      {% for message in messages %}
                                        <p>{{message|safe}}</p>
                                      {% endfor %}
                                  </div>
                              </div>
                          </div>
                      </div>
                  {% endif %}
                {% endwith %}

                {% block body %} {% endblock %}
            </div>
        </div>

    </div>
</div>

{% with messages = get_flashed_messages(with_categories=true) %}
  {% if messages %}
    <script>
    {% for category, message in messages %}

    {% if category != "persistent" %}
      {% if category == "message" %}
      var category = "info";
      {% else %}
      var category = "{{category}}";
      {% endif %}

      $.notify({
          message: "{{message}}"
      }, {
          offset: {
              y: 50,
              x: 30
          },
          type: category
      });
    {% endif %}
    {% endfor %}
    </script>
  {% endif %}
{% endwith %}

</body>
</html>
